#include<sys/epoll.h>
#include<netdb.h>
#include <arpa/inet.h>
#include<sys/socket.h>
#include<pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include<sys/time.h>
#include <ctype.h>
#include <stdbool.h>
#include<dirent.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>
#include<sys/select.h>
#include<sys/wait.h>
#include<signal.h>
#include <crypt.h>

#define ERROR_CHECK(ret,error_val,msg)\
    if((ret)==(error_val)){\
        perror(msg);\
        exit(1);\
    }
#define THREAD_ERROR_CHECK(ret,msg){\
    if((ret)!=(0)){\
        fprintf(stderr,"%s:%s\n",msg,strerror(ret));}}
#define ARGS_CHECK(argc,num)\
    if((argc)!=(num)){\
        fprintf(stderr,"Usage:%s ...\n",argv[0]);\
        exit(1);\
    }
//用户命令的状态码
typedef enum{
    OP_ERR = -1,
    OP_SUC,
    OP_CD,
    OP_PWD,
    OP_LS,
    OP_MKDIR,
    OP_RMDIR,
    OP_PUTS,
    OP_GETS,
    OP_LOGIN
}OP;
typedef struct train_s{
   int tag;
   int length;
   char data[4096];
}train_t;                                                                                                                         
int mystrtok(char*str,char *data);
typedef int socket_t;
int tcp_connect(char *ip,int port);
int get_last_segment(const char* path,char* ret);
int upload(int fd,char *filename);
int download(int fd,char *filename);
int cli_upload(int fd,char *filename);
int login(int sockfd);
